# Generic make file for LaTeX: requires GNU make

TEXFILE = deep-kkozlov-bif-2014.tex
TARGZ = tar zcvf
EXTRA_DIST = *.eps *.sty

.PHONY: dvi ps pdf clean veryclean dist

pdf:	$(TEXFILE:.tex=.pdf)
ps:	$(TEXFILE:.tex=.ps)
dvi:	$(TEXFILE:.tex=.dvi)

%.dvi: %.tex
	( \
	latex $<; \
	while grep -q "Rerun to get cross-references right." $(<:.tex=.log); \
	do \
		latex $<; \
	done \
	)
	bibtex $(<:.tex=)
	( \
	latex $<; \
	while grep -q "Rerun to get cross-references right." $(<:.tex=.log); \
	do \
		latex $<; \
	done \
	)

%.ps: %.dvi
	dvips $< -o $(<:.dvi=.ps)

%.pdf: %.ps
	ps2pdf $<

clean:
	@rm -f \
	$(TEXFILE:.tex=.aux) \
	$(TEXFILE:.tex=.bbe) \
	$(TEXFILE:.tex=.log) \
	$(TEXFILE:.tex=.out) \
	$(TEXFILE:.tex=.dvi) \
	$(TEXFILE:.tex=.pdf) \
	$(TEXFILE:.tex=.toc) \
	$(TEXFILE:.tex=.ps)

veryclean: clean
	@rm -f \
	$(TEXFILE:.tex=.bbl) \
	$(TEXFILE:.tex=.blg) \
	$(TEXFILE:.tex=.bm)

dist:
	$(TARGZ) \
	$(TEXFILE:.tex=.tgz) \
	$(TEXFILE) \
	$(EXTRA_DIST) \
	$(TEXFILE:.tex=.pdf)

